$(function() {
    $(document).on('click', '[data-role="adviceSetting-del"]', function() {
        $(this).parent('.adviceSetting-item').remove();
    })

    $('[data-role="adviceSetting-add"]').on('click', function() {
        var html = '<div class="adviceSetting-item">\
                        <input type="text" value="">\
                        <span data-role="adviceSetting-del"></span>\
                    </div>';
        $('.adviceSetting-inner').append(html);
    })

    // 提交数据
    $('[data-role="adviceSetting-submit"]').on('click', function() {
        var $input = $('.adviceSetting input');
        var inputValArr = [];
        var inputVal = '';

        for(var i = 0, len = $input.length;i < len;i++) {
            var val  = $input.eq(i).val();
            if(val.trim() != '') {
                inputValArr.push(val);
            }
        }
        inputVal = inputValArr.join('|');
        console.log(inputVal)
    })
})
